<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="/html/js/axios.min.js"></script>
    <script src="/html/js/ajax.js"></script>
    <script>
        window.onload = function (){
            findDept();
        }

        async function findDept(){
            var info = await ajaxGet("/dept/findAll");
            var str = "";
            for(var i=0;i<info.length;i++){
                var obj = info[i];
                str +=  `<option value="${obj.id}">${obj.name}</option>`;
            }
            $("deptSelect").innerHTML = str;
        }

        async function add(){
            var param = {
                name:$("name").value,
                money:$("money").value,
                birthday:$("birthday").value,
                deptId:$("deptSelect").value
            };
            var info = await ajaxPost("/employee/add",param);
            if(info == "ok"){
                location.href = "/html/index.html";
            }
            else{
                alert("添加失败");
            }
        }
    </script>
</head>
<body>
    姓名：<input type="text" id="name"><br>
    生日：<input type="text" id="birthday"><br>
    工资：<input type="text" id="money"><br>
    部门：<select id="deptSelect"></select><br>
    <input type="button" value="添加" onclick="add()">

</body>
</html>